package se.webbzon.boltzmann.minigame.botany;

import java.awt.Rectangle;

import se.webbzon.boltzmann.camera.AbstractCamera;
import se.webbzon.boltzmann.debug.Debug;
import se.webbzon.boltzmann.environment.DefaultEnvironment;
import se.webbzon.boltzmann.input.Input;
import se.webbzon.boltzmann.minigame.Puzzle;
import se.webbzon.boltzmann.minigame.sandbox.DefaultSandBoxContainer;
import se.webbzon.boltzmann.minigame.sandbox.SandBox;
import se.webbzon.boltzmann.minigame.sandbox.SandBoxCursor;
import se.webbzon.boltzmann.minigame.sandbox.SandBoxItem;
import se.webbzon.boltzmann.world.DefaultWorldLoader;
import se.webbzon.oschi01.worldarea.WorldArea;
import se.webbzon.oschi01.worldcamera.WorldView;

public class BotanyGame extends Puzzle {
	
	/*============================================================
	Constructors
	============================================================*/
	
	public BotanyGame() {
		super("puzzles/botany");
	}
	
	/*============================================================
	Protected Methods
	============================================================*/

	@Override protected WorldArea loadPuzzle(WorldView view, Input input) {
		try {
			DefaultEnvironment env = new DefaultEnvironment();
			DefaultWorldLoader loader = new DefaultWorldLoader(env,"euler/r102");
			WorldArea world = loader.load();
			//DummyCamera camera = new DummyCamera();
			//camera.addView(view);
			//world.createInstance(camera);
			world.findInstances(AbstractCamera.class).iterator().next().addView(view);
			
			//box.addItem(container);
			return world;
		} catch (Exception e) {
			Debug.report(e);
			return null;
		}
	}
	
	@Override protected void loadSandBox(SandBox box) {
		SandBoxCursor cursor = new SandBoxCursor();
		box.addItem(cursor);
		//DefaultSandBoxContainer container = new DefaultSandBoxContainer();
		Rectangle r = new Rectangle();
		box.getBoundary(r);
		//container.setPosition(r.x + 32, r.y + 32);
		//box.addItem(container);
		SandBoxItem item = new AnimalCell();
		item.setPosition(64, 64);
		box.addItem(item);
		item = new PlantCell();
		item.setPosition(128, 64);
		box.addItem(item);
		item = new WaterMolecule();
		item.setPosition(192, 64);
		box.addItem(item);
		//container.setContent(item);
	}

	@Override protected void onBegin(WorldArea world) {
		// TODO Auto-generated method stub
		
	}

	@Override protected void onEnd(WorldArea world) {
		// TODO Auto-generated method stub
		
	}

}
